﻿using BCCommon;
using BCDto.TMS.MoveHouseConfig.MoveHouseServicePriceConfig;
using BCDto.TMS.MoveHouseConfig.MoveHouseServicePriceConfig.MoveHouseServicePriceConfigRequest;
using BCDto.TMS.MoveHouseConfig.MoveHouseSpecificationServiceConfig;
using BCDto.TMS.MoveHouseConfig.MoveHouseSpecificationServiceConfig.MoveHouseSpecificationServiceConfigRequest;
using BCService.TMS.MoveHouseConfig.MoveHouseServicePriceConfig;
using BCService.TMS.MoveHouseConfig.MoveHouseSpecificationServiceConfig;
using BCTMSRESTful.Configs;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace BCTMSRESTful.Controllers.Management.TMS.MoveHouseConfig
{
    /// <summary>
    /// 搬家服务价格设置
    /// </summary>
    [Route("api/v1/sim/[controller]")]
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    public class MoveHouseServicePriceConfigController : ManagementBaseController
    {
        private readonly IMoveHouseServicePriceConfigService moveHouseServicePriceConfigService;
        public MoveHouseServicePriceConfigController(IMoveHouseServicePriceConfigService moveHouseServicePriceConfigService)
        {
            this.moveHouseServicePriceConfigService = moveHouseServicePriceConfigService;
        }

        ///// <summary>
        ///// 获取供应商搬家价格配置
        ///// </summary>
        ///// <param name="provinceCode">省编码</param>
        ///// <param name="cityCode">市编码</param>
        ///// <param name="countyCode">区编码</param>
        ///// <param name="isEnabled">是否可用</param>
        ///// <returns>获取供应商搬家价格配置</returns>
        //[HttpGet]
        //[Log("获取供应商搬家价格配置")]
        //[ProducesResponseType(typeof(IEnumerable<MoveHouseServicePriceConfigAgentViewDto>), 200)]
        //public IActionResult GetAgentPriceList([FromQuery(Name = "province_code")] string provinceCode,
        //    [FromQuery(Name = "city_code")] string cityCode,
        //    [FromQuery(Name = "county_code")] string countyCode,
        //    [FromQuery(Name = "is_enabled")] bool? isEnabled)
        //{
        //    var result = this.moveHouseServicePriceConfigService.GetAgentPriceList(provinceCode, cityCode,
        //        countyCode, isEnabled, this.Admin);
        //    return this.Ok(result);
        //}


        /// <summary>
        /// 修改搬家规格服务价格配置
        /// </summary>
        /// <param name="moveHouseSpecificationConfigId">搬家规格配置id</param>
        /// <param name="specificationServiceConfigId">搬家服务设置id</param>
        /// <param name="requestDto">搬家服务价格配置</param>
        /// <response code="201">修改搬家规格服务价格配置。</response>
        /// <returns></returns>
        [HttpPut("{move_house_specification_config_id}/{specification_service_config_id}")]
        [Log("修改搬家规格服务价格配置")]
        [ProducesResponseType(typeof(bool), 200)]
        public IActionResult UpdatePrice([FromRoute(Name = "move_house_specification_config_id")] long moveHouseSpecificationConfigId,
            [FromRoute(Name = "specification_service_config_id")] long specificationServiceConfigId,
            [FromBody] MoveHouseServicePriceConfigRequestDto requestDto)
        {
            var result = this.moveHouseServicePriceConfigService.UpdatePrice(moveHouseSpecificationConfigId, specificationServiceConfigId,
                requestDto, this.Admin);
            return this.Ok(result);
        }


        /// <summary>
        /// 修改价格是否可用
        /// </summary>
        /// <param name="moveHouseSpecificationServiceConfigId">价格设置id</param>
        /// <param name="moveHouseSpecificationServiceConfigOverWriteId">价格重写设置id</param>
        /// <param name="enabled"></param>
        /// <returns></returns>
        [HttpPut("[action]/{move_house_service_price_config_id}/{enabled}")]
        [Log("修改搬家规格服务价格配置")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Enabled([FromRoute(Name = "move_house_specification_service_config_id")] long moveHouseSpecificationServiceConfigId,
            [FromQuery(Name = "move_house_specification_service_config_over_write_id")] long? moveHouseSpecificationServiceConfigOverWriteId,
            [FromRoute(Name = "enabled")] bool enabled)
        {
            if (enabled)
                this.moveHouseServicePriceConfigService.Enabled(moveHouseSpecificationServiceConfigId, moveHouseSpecificationServiceConfigOverWriteId, this.Admin);
            else
                this.moveHouseServicePriceConfigService.Disabled(moveHouseSpecificationServiceConfigId, moveHouseSpecificationServiceConfigOverWriteId, this.Admin);
            return NoContent();
        }
    }
}
